package cn.school.web;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author oldliu
 * @since 1.0
 */
@WebServlet("/showSession")
public class ShowSessionServlet extends HttpServlet
{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HttpSession session = req.getSession();
//        long creationTime = session.getCreationTime();
//        long lastVisit=session.getLastAccessedTime();
//        session.getMaxInactiveInterval();

        resp.setContentType("text/html;charset=utf-8");
        PrintWriter out = resp.getWriter();
        out.println("<html>");
        out.println("<body>");
        out.println("<h1>");
        out.println("session id："+session.getId());
        session.setAttribute("time","11:43");
        out.println("</h1>");
        out.println("<h1>");
        out.println("赛zhi成功");
        out.println("</h1>");
        out.println("</body>");
        out.println("</html>");
    }
}
